gint drag_threshold;
GdkEventSequence *sequence;
+ GdkDevice *device;
+ guint button;
guint timeout;
gint start_x;
gint start_y;
priv->timeout = 0;
priv->sequence = NULL;
+ priv->device = NULL;
+ priv->button = 0;
}
static gboolean
{
GtkPressAndHoldPrivate *priv = pah->priv;
- /* We're already tracking a different touch, ignore */
+ /* We're already tracking a different input, ignore */
if ((event->type == GDK_TOUCH_BEGIN && priv->sequence != NULL) ||
- (event->type != GDK_TOUCH_BEGIN && priv->sequence != event->touch.sequence))
+ (event->type == GDK_BUTTON_PRESS && priv->device != NULL) ||
+ (event->type == GDK_TOUCH_UPDATE && priv->sequence != event->touch.sequence) ||
+ (event->type == GDK_TOUCH_END && priv->sequence != event->touch.sequence) ||
+ (event->type == GDK_TOUCH_CANCEL && priv->sequence != event->touch.sequence) ||
+ (event->type == GDK_BUTTON_RELEASE && priv->device != event->button.device) ||
+ (event->type == GDK_BUTTON_RELEASE && priv->button != event->button.button) ||
+ (event->type == GDK_MOTION_NOTIFY && priv->device != event->motion.device))
return;
- priv->x = event->touch.x;
- priv->y = event->touch.y;
-
if (event->type == GDK_TOUCH_BEGIN)
{
priv->sequence = event->touch.sequence;
+ priv->x = event->touch.x;
+ priv->y = event->touch.y;
priv->start_x = priv->x;
priv->start_y = priv->y;
priv->timeout =
}
else if (event->type == GDK_TOUCH_UPDATE)
{
+ priv->x = event->touch.x;
+ priv->y = event->touch.y;
if (ABS (priv->x - priv->start_x) > priv->drag_threshold ||
ABS (priv->y - priv->start_y) > priv->drag_threshold)
press_and_hold_cancel (pah);
{
press_and_hold_cancel (pah);
}
+ else if (event->type == GDK_BUTTON_PRESS)
+ {
+ priv->device = event->button.device;
+ priv->button = event->button.button;
+ priv->x = event->button.x;
+ priv->y = event->button.y;
+ priv->start_x = priv->x;
+ priv->start_y = priv->y;
+ priv->timeout =
+ gdk_threads_add_timeout (priv->hold_time, hold_action, pah);
+ }
+ else if (event->type == GDK_BUTTON_RELEASE)
+ {
+ press_and_hold_cancel (pah);
+ }
+ else if (event->type == GDK_MOTION_NOTIFY)
+ {
+ priv->x = event->motion.x;
+ priv->y = event->motion.y;
+ if (ABS (priv->x - priv->start_x) > priv->drag_threshold ||
+ ABS (priv->y - priv->start_y) > priv->drag_threshold)
+ press_and_hold_cancel (pah);
+ }
}
GtkPressAndHold *